<template>
  <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="订单详情" width="900px">
    <Description @register="registerDescription" :data="detailData" />
  </BasicDrawer>
</template>
<script lang="ts" setup>
import {ref, useAttrs} from 'vue';
import {BasicDrawer, useDrawerInner} from '/@/components/Drawer';
import {Description, useDescription} from '/@/components/Description/index';
import {formDetailSchema} from './order.data';
import {getTradeData} from './order.api';

const emit = defineEmits(['register']);
  const attrs = useAttrs();
  const detailData = ref({});
  const [registerDescription] = useDescription({
    column: 4,
    bordered: false,
    // data: mockData,
    schema: formDetailSchema,
    labelStyle: {
      marginLeft: '10px'
    }
  });

  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
    setDrawerProps({ confirmLoading: false });
    const tradeData = await getTradeData({
      payOrderNo: data.record.payOrderNo,
      mchNo: data.record.mchNo,
      appId: data.record.appId,
    })
    data.record.tradeContent = tradeData?.tradeContent
    data.record.tradeType = tradeData?.tradeType
    detailData.value = data.record;
  });
</script>
